<m_include file="Public:head" />
<body>
<m_include file="Public:nav" />
<div class="main">
	<div class="line">
		<input type="text" name="mobile" class="ipt_txt" placeholder="输入手机号" style="width:calc(100% - (138px))"/>
        <input type="button" class="btn" id="code" value="获取验证码" style="width:110px" /></div>
    <div class="line">
    	<input type="text" name="rancode" class="ipt_txt" maxlength="6" placeholder="输入验证码" style="width:calc(100% - (22px))" />
	</div>
    <div class="line">
    	 <input type="button" id="go" class="btn" value="查询订单" style="width:100%"></div>
    </div>
<m_include file="Public:foot" />
<m_include file="Public:script" />
<script>	
var iTime = 59;
var Account;
function RemainTime(){	
	var iSecond,sSecond="",sTime="",btn = $('#code') ;
	btn.attr('disabled',true);
	if (iTime >= 0){
		iSecond = parseInt(iTime%60);
		iMinute = parseInt(iTime/60)
		if (iSecond >= 0){
			if(iMinute>0){
				sSecond = iMinute + "分" + iSecond + "秒";
			}else{
				sSecond = iSecond + "秒";
			}
		}
		sTime=sSecond;
		if(iTime==0){
			clearTimeout(Account);
			sTime='获取验证码';
			iTime = 59;
			btn.attr('disabled',false);
		}else{
			Account = setTimeout("RemainTime()",1000);
			iTime=iTime-1;
		}
	}else{
		sTime='没有倒计时';
	}
	btn.val(sTime);
}

$(document).on('click','#code',function(){

	var t = $("input[name^='mobile']");
	if(!check_mobile(t.val())){
	m(t.focus()); return}
	RemainTime();

	$.post('/api/sms', {mobile:t.val()}, function(msg) {
		if(msg == 1){}
	});
})

$('#go').on('click',function(){
		var t = $("input[name^='mobile']");
		if(!check_mobile(t.val())){
			m(t.focus()); return
		}
		var c = $("input[name^='rancode']");
		if(c.val().length == 0){
			m(c.focus()); return
		}
		$.post('/user/ajax_login',{mobile:t.val(),randcode:c.val()},function(msg){
			if(msg.status==1)
			{
				location = '/user/order';
			}else{ alert(msg.info);}
		})
	});
</script>
</body>
</html>
